import QtQuick 2.0

Item {

    id: root

    property int idx: 0
    property var msgList: []

    property int mode: 0


    // 请自行分配一块消息区域
    height: parent.height
    width: parent.width

    property int maxShowLength: 10000


    function show(msg, type){
        msgList.push({
                         "msg": msg,
                         "type": type
                     })
        msgListChanged()
    }
    function remove(idx){
        msgList.splice(idx, 1)
        msgListChanged()
    }


    Column{
        anchors.fill: parent
        spacing: 5*dp
        Repeater{
            id: repeater
            model: msgList.length
            delegate: Item{
                width: parent.width
                height: {
                    if(mode === 0) return 36*dp
                    if(mode === 1) return 66*dp
                }

                CustomMessageListItem1{
                    visible: mode === 0 && maxShowLength > index
                    text: msgList[index]["msg"]
                    type: msgList[index]["type"]
                    onClose: {
                        remove(index)
                    }
                }CustomMessageListItem2{
                    visible: mode === 1 && maxShowLength > index
                    text: msgList[index]["msg"]
                    type: msgList[index]["type"]
                    onClose: {
                        remove(index)
                    }
                }
            }

        }
    }





}
